import request from '@/service/lib/request';
import hiSetting from '@/hiSetting'

//查询信息列表
export function infoList(msgType, haveRead) {
    return request({
        url: hiSetting.server + "/messageApi/find",
        method: 'get',
        params: { msgType, haveRead },

    });
}
//查看信息
export function seeInfo(recordId) {
    return request({
        url: hiSetting.server + "/messageApi/get",
        method: 'get',
        params: { recordId },

    });
}
//删除信息
export function removeInfo(data) {
    return request({
        url: hiSetting.server + "/messageApi/remove",
        method: 'post',
        data,

    });
}
//发送信息
export function sendInfo(data) {
    return request({
        url: hiSetting.server + "/messageApi/add",
        method: 'post',
        data

    });
}
// 设为已读
export function setread(recordId, data) {
    return request({
        url: hiSetting.server + "/messageApi/setread",
        method: 'post',
        params: { recordId },
        data,
        transformRequest: [
            function (data) {
                let ret = ''
                for (let it in data) {
                    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                }
                ret = ret.substring(0, ret.lastIndexOf('&'));
                return ret
            }
        ],
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
}